package com.sc.byahi.user.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;

public class Error extends Composite {

	private static ErrorUiBinder uiBinder = GWT.create(ErrorUiBinder.class);

	interface ErrorUiBinder extends UiBinder<Widget, Error> {
	}

	public Error() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiField
	Image image;

	@UiField
	SpanElement description;

	public static final String ERROR="ERROR";
	public static final String WARNING="WARNING";
	public static final String INFO="INFO";
	
	public void setError(String type, String text) {
		if (ERROR.equals(type)) {
			image.setUrl("/images/e_error.png");
		} else if (WARNING.equals(type)) {
			image.setUrl("/images/e_warning.png");
		} else if (INFO.equals(type)) {
			image.setUrl("/images/e_info.png");
		}
		this.description.setInnerText(text);
	}

}
